
//  MapLeftSideViewController.m
//  PrivateSteward
//
//  Created by lanou3g on 16/3/23.
//  Copyright © 2016年 闫贺晨. All rights reserved.
//

#import "MapLeftSideViewController.h"

@interface MapLeftSideViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,assign)NSInteger count;
@property (nonatomic,strong)UITableView *tableView;
@end

@implementation MapLeftSideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bjtutu1.jpg"]];
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width/3*2, [UIScreen mainScreen].bounds.size.height - self.navigationController.navigationBar.bounds.size.height - self.tabBarController.tabBar.frame.size.height) style:(UITableViewStyleGrouped)];
    self.tableView.backgroundColor = [UIColor clearColor];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    [self.view addSubview:self.tableView];
    
    
    self.count = 2;
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 6;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 5) {
        return self.count;
    }
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 50;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 50)];
    view.backgroundColor = [UIColor purpleColor];
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 0, 50, 50)];
    button.backgroundColor = [UIColor greenColor];
    [button addTarget:self action:@selector(showMoreAction:) forControlEvents:(UIControlEventTouchDown)];
    button.tag = 100+section;
    [view addSubview:button];
    [[NSUserDefaults standardUserDefaults] setInteger:section forKey:@"showMore"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    return view;
}
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"cell"];
    cell.backgroundColor = [UIColor redColor];
    return cell;
}

- (void)showMoreAction:(UIButton*) button{
    if (button.tag == 105) {
        if (self.count != 5) {
            self.count = 5;
            [self.tableView reloadData];
        }
        else{
            self.count = 2;
            [self.tableView reloadData];
        }
        
        
        
    }
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end